﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using Miris.HumanMilkAnalyser.DataModel;
using Miris.HumanMilkAnalyser.Service.Validation;

namespace Miris.HumanMilkAnalyser.WPF.ValidationRules
{
    public class BreastfeedingSignificanceTitleValidationRule : ValidationRule
    {
        public override ValidationResult Validate(object value, System.Globalization.CultureInfo cultureInfo)
        {
            var itemValidator = new BreastfeedingSignificanceValidator();

            var item = new BreastfeedingSignificance
            {
                Title = value.ToString().Trim()
            };

            if (!itemValidator.CheckRequiredTitle(item))
            {
                return new ValidationResult(false, itemValidator.GetError(BreastfeedingSignificanceValidator.TitleErrorKey));
            }

            return ValidationResult.ValidResult;
        }
    }

    public class BreastfeedingSignificanceContentValidationRule : ValidationRule
    {
        public override ValidationResult Validate(object value, System.Globalization.CultureInfo cultureInfo)
        {
            var itemValidator = new BreastfeedingSignificanceValidator();

            var item = new BreastfeedingSignificance
            {
                SignificanceContent = value.ToString().Trim()
            };

            if (!itemValidator.CheckRequiredSignificanceContent(item))
            {
                return new ValidationResult(false, itemValidator.GetError(BreastfeedingSignificanceValidator.SignificanceContentErrorKey));
            }

            return ValidationResult.ValidResult;
        }
    }
}
